function thread_init(thread_id)
   drv = sysbench.sql.driver()
   con = drv:connect()
end

function cleanup()
  local drv = sysbench.sql.driver()
  local con = drv:connect()
  con:query("truncate table se_compose_txn_log_3")
end

function thread_done()
  con:disconnect()
end

function event()
   local table_name
   local c_val
   local k_val
   local pad_val

   table_name = "se_compose_txn_log_3"
   local a_temp = "######"
   local b_temp = "#########"

   --k_val = tostring(sb_rand(100000, 999999)+sb_rand(100000000, 999999999))
   --c_val = tostring(sb_rand(100000, 999999)+sb_rand(100000000, 999999999))
   --pad_val = tostring(sb_rand(100000, 999999)+sb_rand(100000000, 999999999))
   k_val = sysbench.rand.string(b_temp)
   c_val = sysbench.rand.string(b_temp)
   pad_val = tostring(sysbench.rand.unique() -  2147483648)

   rs = conn:query(string.format("INSERT INTO %s (tx_date,global_busi_track_no,subtx_no,start_sys_or_cmpt_no,send_sys_or_cmpt_no, " ..
                  "start_chn1_fg_cd,busi_send_inst_no,data_center_code,tx_start_time,tx_send_time,target_sys_or_cmpt_no,serv_tp_cd, " ..
                  "serv_no,compose_code,serv_ver_no,req_sys_sri_no,core_tx_date,org_req_sys_sri_no,accounting_date,core_tx_time, " ..
                  "main_tx_time,txn_used_time,tx_status,saga_status,extract_flag,create_stamp,last_mod_stamp,redo_seq, " ..
                  "serv_return_type_code,serv_resp_cd,serv_resp_desc_info,zone_val,req_msg,resp_msg,instance_id,core_sys_serial_no,inner_resp_cd,field1,field2) VALUES " ..
                  "('20201124','%s','%s','F000001','F000001','01','instNooo','Y','20200909202020001','20200909202020001','F000002','1','T123456PT01','T123456PT01', " ..
                  "NULL,'2021077317321202021200123',NULL,NULL,'20201124',NULL,'500000','0','2','-1','0', '2021-02-18 22:23:01.29', '2021-02-18 22:23:03.318', " ..
                  "0,'03','XT123456ATSE3000','系统错误','621300000000003189322', " ..
                  "\'{\"txHeader\":\"startSysOrCmptNo\":\"F000001\",\"sendSysOrCmptNo\":\"F000007\",\"startChn1FgCd\":\"01\",\"busiSendInstNo\":\"instNooo\",\"dataCenterCode\":\"Y\",\"txStartTime\":\"20200909202020001\", " ..
                  "\"txSendTime\":\"20200909202020001\",\"msgrptTotalLen\":\"999\",\"msgrptFmtVerNo\":\"000001\",\"msgAgrType\":\"T\",\"pubMsgHeadLen\":\"999\",\"embedMsgrptLen\":\"999\", " ..
                  "\"targetSysOrCmptNo\":\"F000002\",\"servTpCd\":\"1\",\"servNo\":\"T123456PT01\",\"servVerNo\":\"000001\",\"globalBusiTrackNo\":\"11111164629372760549698570904509\",\"subtxNo\":\"16058625684698579764456105283235\", " ..
                  "\"reqSysSriNo\":\"2021077317321202021200123\",\"mainMapElementInfo\":\"info\",\"resvedInputInfo\":\"info\",\"coreTxDate\":\"20201124\",\"maxTxnTime\":\"500000\",\"txnUsedTime\":\"0\",\"cusId\":\"621300000000003189322\", " ..
                  "\"shardingId\":\"1\",\"dbId\":\"1\",\"dusId\":\"B001\",\"tableId\":\"000\",\"custInfoMap\":{},\"execRetryTimes\":0,\"redoSeq\":0,\"stepSeq\":0,\"coreSysSerialNo\":\"000120210115204402712345698230000001\",\"oldServTpCd\":\"1\", " ..
                  "\"reservedMap\":{},\"txBody\":{\"txCommon\":{\"engineInfo\":{},\"lockInfo\":{},\"sagaInfo\":{},\"authInfoList\":\[\],\"appSharedInfo\":{},\"appAddToShared\":{},\"txScopeShared\":{},\"msgAttrInfo\":{}}, " ..
                  "\"txComni\":\"accountingDate\":\"20201124\",\"txComn1\":{\"bgnIndexNo\":0,\"curQryReqNum\":0},\"txComn2\":{},\"txComn3\":{},\"txComn4\":{},\"txEntity\":{\"accountingNo\":\"622800000000000000000100000237\"}}}\\\', " ..
                  "NULL, '20.0.12.32','%s','XT123456ATSE3000','',NULL)", table_name, k_val, c_val, pad_val))

end
